<?php
    $user = $_REQUEST['user'];
    $pwd = $_REQUEST['pwd'];
    $type = $_REQUEST['type'];
    
    $conn = mysqli_connect('127.0.0.1','root','root','vivo');
    
    //查询函数
    $sql = "SELECT * FROM `userinfo` WHERE `user`='$user' AND `pwd`='$pwd'";
    $rus = mysqli_query($conn,$sql);
    $data = mysqli_fetch_assoc($rus);
    // var_dump($data);
    if($data!=null){//查询到数据返回1
        if($type=='1'){
            setcookie('uname',$user,time()+7*24*60*60,'/');
            setcookie('upass',$pwd,time()+7*24*60*60,'/');
        }else{
            setcookie('uname',$user,null,'/');
            setcookie('upass',$pwd,null,'/');
        }
        echo '{"code":1}'; //查询成功返回1
        
    }else{
        echo '{"code":0}'; //查询失败返回0
    }
    
?>